<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{if $operFlg == 2}-->修改<!--{else}-->添加<!--{/if}--><!--{$category_array->itemCategoryName}--></title>
    <!--{include file='comm/comm_pic.tpl'}-->
</head>
<body>
<div style="width:100%">

    <div class="items clearfix">
        <h2 style="" class="tal">正在操作：<!--{if $operFlg == 2}-->修改<!--{else}-->添加<!--{/if}--><!--{$category_array->itemCategoryName}--></h2>
        <div class="items2">

            <!--{if $error_msg}-->

            <div class="error-box">
                <!--{$error_msg}-->
            </div>

            <!--{else}-->

            <div>
                <form id="item_form" onsubmit="return false;">
                    <table>
                        <tbody>
                        <!--{if $category_array->itemCategoryID == 13}-->
                        <tr>
                            <td class="tar" width="150"><!--{$category_array->itemCategoryName}-->内容：</td>
                            <td width="500">
                                <textarea rows="3" cols="20" id="itemName" name="itemName"><!--{$item_array->itemName}--></textarea>
                                <!--{if $operFlg == 2}-->
                                <input type="hidden" value="<!--{$item_array->itemID}-->" id="itemID" name="itemID" />
                                <!--{/if}-->
                                <input type="hidden" value="<!--{$category_array->itemCategoryID}-->" id="item_category_ID" name="item_category_ID" />
                            </td>
                        </tr>
                        <!--{else}-->
                        <tr>
                            <td class="tar" width="150"><!--{$category_array->itemCategoryName}-->名称：</td>
                            <td width="500">
                                <input type="text" value="<!--{$item_array->itemName}-->" id="itemName" name="itemName" />
                               	<!--{if $operFlg == 2}-->
                                <input type="hidden" value="<!--{$item_array->itemID}-->" id="itemID" name="itemID" />
                                <!--{/if}-->
                                <input type="hidden" value="<!--{$category_array->itemCategoryID}-->" id="item_category_ID" name="item_category_ID" />
                            </td>
                        </tr>
                        <!--{/if}-->
                        <tr>
                            <td class="tar"><!--{$category_array->itemCategoryName}-->状态：</td>
                            <td>
                            <!--{if $item_array->useFlg != '0' && $item_array->useFlg != '1'}-->
                            	<input type="radio" value="1" name="useFlg" checked />启用
                            	<input type="radio" value="0" name="useFlg" />禁用
                            <!--{else}-->
                            	<input type="radio" value="1" name="useFlg" <!--{if $item_array->useFlg == 1}-->checked<!--{/if}--> />启用
                            	<input type="radio" value="0" name="useFlg" <!--{if $item_array->useFlg == 0}-->checked<!--{/if}-->/>禁用
                            <!--{/if}-->
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>

            <!--{/if}-->

        </div>
    </div>


    <div class="bottom_fixbox">
        <div class="rectbox tac">
            <input type="button" class="btn" onclick="item.check();" value="<!--{if $operFlg == 2}-->修改<!--{else}-->添加<!--{/if}--><!--{$category_array->itemCategoryName}-->" />&nbsp;&nbsp;&nbsp;
            <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
        </div>
    </div>


</div>

<script type="text/javascript">

    var item = {
		item_category_ID:<!--{$category_array->itemCategoryID}-->,

        <!--{if $category_array->itemCategoryID == 13}-->
        itemCategoryName:'<!--{$category_array->itemCategoryName}-->'+'内容',
        <!--{else}-->
        itemCategoryName:'<!--{$category_array->itemCategoryName}-->'+'名称',
        <!--{/if}-->

        itemID: <!--{$item_array->itemID|default:0}-->,
        
        operFlg:<!--{$operFlg}-->,

        //检查数据
        check: function() {
            this.dt = E.getFormValues("item_form");
            var error_msg = "";
            if (this.dt.itemName == "")
                error_msg += this.itemCategoryName + "不能为空<br />";
            if (this.dt.useFlg != '0' && this.dt.useFlg != '1')
                error_msg += this.itemCategoryName + "未选择<br />";
                
            if (error_msg != "")
                E.alert(error_msg);
            else
                item.add();
        },

        //保存信息
        add: function() {
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/item/item.ajax?operFlg=2",
                dataType: "JSON",
                data: this.dt,
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        E.opener("item.load");
                        if (item.operFlg == 2){ //编辑
                        	E.alert(result_obj.message, 2, "E.closeWindows");
                        }else if (item.operFlg == 3){ //添加 
                        	E.alert(result_obj.message, 2,"E.refresh");
                        }
                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        }

    };
    
</script>

</body>

</html>
